package br.eck.model.base;

import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;

/**
 * Representa todo e qualquer objeto do jogo
 * 
 * @author Erick Zanardo
 * 
 */
public abstract class GameObject {
    /** Coordenada x do plano */
    private float x;
    /** Coordenada y do plano */
    private float y;
    /** Imagem do objeto */
    private Image image;

    public float getX() {
        return x;
    }

    public void setX(float x) {
        this.x = x;
    }

    public float getY() {
        return y;
    }

    public void setY(float y) {
        this.y = y;
    }

    public Image getImage() {
        return image;
    }

    public void setImage(Image image) {
        this.image = image;
    }

    /**
     * Retorna se um objeto se chocou com o outro
     * 
     * @param obj
     * @return
     */
    public boolean hasHit(GameObject obj) {
        return ((getY() + getImage().getHeight() >= obj.getY() && getY() <= (obj.getY() + obj.getImage().getHeight())) &&
                (getX() + getImage().getWidth() >= obj.getX() && getX() <= (obj.getX() + obj.getImage().getWidth())));
    }

    /**
     * Desenha este objeto na tela
     * 
     * @param g
     */
    public void draw(Graphics g) {
        g.drawImage(image, x, y);
    }

    public abstract void update(int timePassed, Input input);
}
